package com.laxia.dao.impl;

import com.laxia.domain.mapper.AdminUserMapper;
import com.laxia.domain.entity.AdminUser;
import com.laxia.dao.AdminUserDAO;

import com.laxia.mybatis.BaseMapper;

import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import tk.mybatis.mapper.entity.Example;

/**
 * @author mybatis generator
 */
@Slf4j
@Service
@AllArgsConstructor
public class AdminUserDAOImpl extends BaseDAOImpl<AdminUser> implements AdminUserDAO {

    private AdminUserMapper mapper;

    @Override
    protected BaseMapper<AdminUser> mapper() {
        return mapper;
    }


    @Override
    public AdminUser getByUsername(String username) {
        Example example = this.example(AdminUser.class);
        Example.Criteria criteria = example.createCriteria();
        criteria.andEqualTo("username", username);
        criteria.andEqualTo("deleted", false);
        return mapper.selectOneByExample(example);
    }
}